<template>
  <div class="prolist">
    <div
      class="list"
      v-for="(item, index) in list"
      @click="goGoodsDetail(item.proid)"
      :key="index"
    >
      <div class="left">
        <img :src="item.img1" alt="" />
      </div>
      <div class="right">
        <div class="name">{{ item.proname }}</div>
        <div class="price">¥{{ item.originprice }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { fun_categorybrandprolist } from "../api/index.js";
import { fun_search } from "../api/index.js";
export default {
  props: ["linkdata","linkdata2"],
  data() {
    return {
      list: [],
    };
  },
  created() {
     fun_search(this.$route.params.data).then((res) => {
        this.list = res.data.data;
      });
                fun_categorybrandprolist(this.$route.params.category,this.$route.params.brand).then((res) => {
             this.list = res.data.data;
           console.log(this.linkdata2);
         });
  },
  watch: {
    linkdata: function () {
      // console.log("watch");
      fun_search(this.linkdata).then((res) => {
        this.list = res.data.data;
      });
    },
  },
  methods: {
    goGoodsDetail(proid) {
      this.$router.push({
        name: "detailview",
        params: {
          proid: proid,
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.list {
  display: flex;
  background-color: #fff;
  padding: 0.2778rem 0.8333rem;
  margin-bottom: 0.5556rem;
}
.left {
  width: 40%;
  margin-right: 0.5556rem;
  img {
    width: 100%;
    border-radius: 0.5556rem;
  }
}
.right {
  width: 100%;
  font-size: 0.7222rem;
  display: flex;
  justify-content: space-between;
  flex-direction: column;
}
.name {
  display: -webkit-box; /*作为弹性伸缩盒子模型显示*/
  -webkit-line-clamp: 2; /*显示的行数；如果要设置2行加...则设置为2*/
  overflow: hidden; /*超出的文本隐藏*/
  text-overflow: ellipsis; /* 溢出用省略号*/
  -webkit-box-orient: vertical; /*伸缩盒子的子元素排列：从上到下*/
}
</style>